package com.itheima.sh.Test;

import java.util.ArrayList;

/*
2. 定义测试类，在main方法中完成以下要求：
                2.1创建三个Movie对象，分别为： "唐山大地震"，"冯小刚","灾难"; "羞羞的铁拳"，"宋阳","喜剧"; "集结号"，"冯小刚","历史";
                    2.2将以上3个对象添加到list集合中
                        2.3遍历集合，将导演为"冯小刚"的电影按照如下格式打印到控制台上。 唐山大地震-冯小刚-灾难 集结号-冯小刚-历史
 */
public class MovieTest {
    public static void main(String[] args) {
        Movie movie = new Movie("唐山大地震", "冯小刚", "灾难");
        Movie movie1 = new Movie("羞羞的铁拳", "宋阳", "喜剧");
        Movie movie2 = new Movie("集结号", "冯小刚", "历史");
        ArrayList<Movie> list = new ArrayList<>();
        list.add(movie);
        list.add(movie1);
        list.add(movie2);
        for (int i = 0; i < list.size(); i++) {
            Movie movie3 = list.get(i);
            String director = movie3.getDirector();
            String title = movie3.getTitle();
            String type = movie3.getType();
            if (director.equals("冯小刚")) {
                System.out.println(title+"-"+director+"-"+type);
            }
        }

    }
}

